package org.apache.commons.exec;

import java.io.IOException;

import org.apache.commons.exec.io.InputStreamWriter;
import org.apache.commons.exec.io.ProcessOutputStreamReader;

public class RunProcess {
	public static void main(String args[]) throws ExecuteException, IOException {
		InputStreamWriter inputStreamWriter=new InputStreamWriter();
		CommandLine commandLine=new CommandLine("java");
		commandLine.addArgument("-classpath").addArgument("target/external-exec-1.4.0-SNAPSHOT-tests.jar").addArgument("org.apache.commons.exec.MockProcess");
		
		DefaultExecutor yolov5Executor=new DefaultExecutor();
		yolov5Executor.setStreamHandler(new DefaultProcessStreamHandler(new Yolov5ProcessOutputStreamReader(), new Yolov5ProcessOutputStreamReader(), inputStreamWriter));
		yolov5Executor.execute(commandLine);
	}
	
	static class Yolov5ProcessOutputStreamReader extends ProcessOutputStreamReader {
		@Override
		protected void processLine(String line, int level) {
			System.out.println(line);
		}
		
	}

}
